(function() {
  var Article, Config, Logger, Message, MongoConfig, Mongoose, RecommendArticle, Reflection, User, conn, mongooseConOptions, mongooseConnectStr;

  Mongoose = require('mongoose');

  Config = require('../config');

  MongoConfig = Config.mongo;

  Logger = require('log4js').getLogger();

  mongooseConnectStr = "mongodb://" + MongoConfig.user + ":" + MongoConfig.pwd + "@" + MongoConfig.host + ":" + MongoConfig.port + "/" + MongoConfig.db;

  Logger.info("mongooseConnectStr:" + mongooseConnectStr);

  mongooseConOptions = {
    server: {
      poolSize: MongoConfig.poolSize
    }
  };

  conn = Mongoose.createConnection(mongooseConnectStr, mongooseConOptions, function(err) {
    if (err) {
      return Logger.error("mongoose error:" + err);
    }
  });

  Article = conn.model('Article', require('./schema/article'));

  Reflection = conn.model('Reflection', require('./schema/reflection'));

  RecommendArticle = conn.model('RecommendArticle', require('./schema/recommend_article'));

  User = conn.model('User', require('./schema/user'));

  Message = conn.model('Message', require('./schema/message'));

  module.exports = {
    Article: Article,
    Reflection: Reflection,
    RecommendArticle: RecommendArticle,
    User: User
  };

}).call(this);
